<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>角色权限管理</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: "Microsoft YaHei", sans-serif;
        }
        body {
            background-color: #f5f7fa;
        }
        .container {
            display: flex;
            height: 100vh;
        }
        .sidebar {
            width: 200px;
            background-color: #fff;
            border-right: 1px solid #e6e6e6;
            padding: 20px 0;
        }
        .main-content {
            flex: 1;
            padding: 20px;
        }
        .header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
        }
        .search-box {
            display: flex;
            align-items: center;
            background-color: #fff;
            border: 1px solid #e6e6e6;
            border-radius: 4px;
            padding: 5px 10px;
            width: 300px;
        }
        .search-box input {
            border: none;
            outline: none;
            flex: 1;
            margin-left: 5px;
        }
        .btn {
            padding: 8px 16px;
            border-radius: 4px;
            cursor: pointer;
            border: none;
            outline: none;
        }
        .btn-primary {
            background-color: #6366f1;
            color: white;
        }
        .btn-default {
            background-color: #fff;
            border: 1px solid #e6e6e6;
            color: #333;
        }
        .role-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0 20px;
            margin-bottom: 10px;
        }
        .role-title {
            font-size: 16px;
            font-weight: bold;
        }
        .role-search-box {
            display: flex;
            align-items: center;
            background-color: #fff;
            border: 1px solid #e6e6e6;
            border-radius: 4px;
            padding: 5px;
            width: 100%;
            margin-top: 10px;
        }
        .role-search-box input {
            border: none;
            outline: none;
            flex: 1;
            font-size: 12px;
        }
        .role-search-actions {
            display: flex;
            align-items: center;
        }
        .search-icon, .add-icon {
            cursor: pointer;
            color: #666;
            font-size: 14px;
            margin-left: 5px;
            width: 20px;
            height: 20px;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .add-icon {
            font-weight: bold;
        }
        .role-list {
            list-style: none;
        }
        .role-group {
            margin-bottom: 10px;
        }
        .role-group-title {
            display: flex;
            align-items: center;
            padding: 8px 20px;
            cursor: pointer;
        }
        .role-group-title.active {
            background-color: #f0f0ff;
        }
        .role-group-title .icon {
            margin-right: 5px;
            transition: transform 0.3s;
        }
        .role-group-title.expanded .icon {
            transform: rotate(90deg);
        }
        .role-item {
            padding: 8px 20px 8px 40px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }
        .role-item.active {
            background-color: #e8e9ff;
            color: #6366f1;
        }
        .role-item .icon {
            color: #6366f1;
        }
        .permission-table {
            width: 100%;
            border-collapse: collapse;
            background-color: #fff;
            border-radius: 4px;
            overflow: hidden;
        }
        .permission-table th, .permission-table td {
            padding: 12px 16px;
            text-align: left;
            border-bottom: 1px solid #e6e6e6;
        }
        .permission-table th {
            background-color: #f9fafb;
            font-weight: normal;
        }
        .permission-table .checkbox {
            width: 18px;
            height: 18px;
            accent-color: #6366f1;
        }
        .module-name {
            font-weight: bold;
            width: 150px;
        }
        .permission-group {
            border-bottom: 1px solid #e6e6e6;
        }
        /* 弹出对话框样式 */
        .modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.5);
            z-index: 1000;
            justify-content: center;
            align-items: center;
        }
        .modal-content {
            background-color: #fff;
            border-radius: 4px;
            width: 400px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        }
        .modal-header {
            padding: 15px 20px;
            border-bottom: 1px solid #e6e6e6;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .modal-header h3 {
            font-size: 16px;
            font-weight: bold;
            margin: 0;
        }
        .close-btn {
            cursor: pointer;
            font-size: 18px;
            background: none;
            border: none;
        }
        .modal-body {
            padding: 20px;
        }
        .form-group {
            margin-bottom: 15px;
        }
        .form-group label {
            display: block;
            margin-bottom: 5px;
            color: #666;
            font-size: 14px;
        }
        .form-group input {
            width: 100%;
            padding: 8px 10px;
            border: 1px solid #e6e6e6;
            border-radius: 4px;
            outline: none;
        }
        .form-group select {
            width: 100%;
            padding: 8px 10px;
            border: 1px solid #e6e6e6;
            border-radius: 4px;
            outline: none;
        }
        .modal-footer {
            padding: 15px 20px;
            border-top: 1px solid #e6e6e6;
            text-align: right;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="sidebar">
            <div class="role-header">
                <div class="role-title">角色分组</div>
            </div>
            <div class="role-search-box">
                <input type="text" placeholder="角色分组">
                <div class="role-search-actions">
                    <div class="search-icon">🔍</div>
                    <div class="add-icon" id="addRoleGroupBtn">+</div>
                </div>
            </div>
            <ul class="role-list">
                <li class="role-group">
                    <div class="role-group-title active">
                        <span class="icon">▶</span>
                        <span>采购角色组</span>
                    </div>
                    <ul class="role-list">
                        <li class="role-item active">
                            <span>采购专员</span>
                            <span class="icon">✓</span>
                        </li>
                        <li class="role-item">
                            <span>采购经理</span>
                        </li>
                        <li class="role-item">
                            <span>采购总监</span>
                        </li>
                    </ul>
                </li>
                <li class="role-group">
                    <div class="role-group-title">
                        <span class="icon">▶</span>
                        <span>财务角色组</span>
                    </div>
                </li>
                <li class="role-group">
                    <div class="role-group-title">
                        <span class="icon">▶</span>
                        <span>销售角色组</span>
                    </div>
                </li>
                <li class="role-group">
                    <div class="role-group-title">
                        <span class="icon">▶</span>
                        <span>仓库角色组</span>
                    </div>
                </li>
            </ul>
        </div>
        <div class="main-content">
            <div class="header">
                <div class="search-box">
                    <span>🔍</span>
                    <input type="text" placeholder="搜索">
                </div>
                <div>
                    <button class="btn btn-primary">全选</button>
                    <button class="btn btn-default">取消全选</button>
                </div>
            </div>
            <table class="permission-table">
                <tr class="permission-group">
                    <td><input type="checkbox" class="checkbox" checked></td>
                    <td class="module-name">供应商管理</td>
                    <td>
                        <input type="checkbox" class="checkbox" checked> 查看
                        <input type="checkbox" class="checkbox" checked> 新增客户
                        <input type="checkbox" class="checkbox" checked> 编辑
                        <input type="checkbox" class="checkbox" checked> 删除
                    </td>
                </tr>
                <tr class="permission-group">
                    <td><input type="checkbox" class="checkbox" checked></td>
                    <td class="module-name">采购管理</td>
                    <td>
                        <input type="checkbox" class="checkbox" checked> 查看
                        <input type="checkbox" class="checkbox" checked> 新增订单
                        <input type="checkbox" class="checkbox" checked> 编辑
                        <input type="checkbox" class="checkbox" checked> 标记删除
                        <input type="checkbox" class="checkbox" checked> 订单上传
                        <input type="checkbox" class="checkbox" checked> 订单审核
                        <input type="checkbox" class="checkbox" checked> 单证生产
                    </td>
                </tr>
                <tr class="permission-group">
                    <td><input type="checkbox" class="checkbox" checked></td>
                    <td class="module-name">采购记录</td>
                    <td>
                        <input type="checkbox" class="checkbox" checked> 采购记录
                        <input type="checkbox" class="checkbox" checked> 上传
                        <input type="checkbox" class="checkbox" checked> 删除
                    </td>
                </tr>
                <tr class="permission-group">
                    <td><input type="checkbox" class="checkbox" checked></td>
                    <td class="module-name">采购订单审核</td>
                    <td>
                        <input type="checkbox" class="checkbox" checked> 查看
                        <input type="checkbox" class="checkbox" checked> 订单物流
                    </td>
                </tr>
                <tr class="permission-group">
                    <td><input type="checkbox" class="checkbox" checked></td>
                    <td class="module-name">采购退货</td>
                    <td>
                        <input type="checkbox" class="checkbox" checked> 查看
                        <input type="checkbox" class="checkbox" checked> 合同附件
                        <input type="checkbox" class="checkbox" checked> 上传附件
                        <input type="checkbox" class="checkbox"> 历史清单
                    </td>
                </tr>
                <tr class="permission-group">
                    <td><input type="checkbox" class="checkbox" checked></td>
                    <td class="module-name">采购招标审核</td>
                    <td>
                        <input type="checkbox" class="checkbox" checked> 查看
                        <input type="checkbox" class="checkbox" checked> 合同结红
                        <input type="checkbox" class="checkbox" checked> 订单处理
                    </td>
                </tr>
                <tr class="permission-group">
                    <td><input type="checkbox" class="checkbox" checked></td>
                    <td class="module-name">客户管理</td>
                    <td>
                        <input type="checkbox" class="checkbox" checked> 查看
                        <input type="checkbox" class="checkbox" checked> 合同物联
                    </td>
                </tr>
                <tr class="permission-group">
                    <td><input type="checkbox" class="checkbox" checked></td>
                    <td class="module-name">物料管理</td>
                    <td>
                        <input type="checkbox" class="checkbox" checked> 查看
                        <input type="checkbox" class="checkbox" checked> 标准物料规格
                        <input type="checkbox" class="checkbox" checked> 申请非标物料
                        <input type="checkbox" class="checkbox" checked> 物料订单审核
                        <input type="checkbox" class="checkbox" checked> 采购申请
                        <input type="checkbox" class="checkbox" checked> 工艺路线审核
                        <input type="checkbox" class="checkbox" checked> 物料规划
                    </td>
                </tr>
                <tr class="permission-group">
                    <td><input type="checkbox" class="checkbox"></td>
                    <td class="module-name">销售管理</td>
                    <td>
                        <input type="checkbox" class="checkbox"> 工单审核
                        <input type="checkbox" class="checkbox"> 工单配送明细
                        <input type="checkbox" class="checkbox"> 订单打包
                        <input type="checkbox" class="checkbox"> 销售订单子系统
                        <input type="checkbox" class="checkbox"> 销售订单出库
                        <input type="checkbox" class="checkbox"> 销售订单出厂
                        <input type="checkbox" class="checkbox"> 销售订单出货
                    </td>
                </tr>
                <tr class="permission-group">
                    <td><input type="checkbox" class="checkbox"></td>
                    <td class="module-name"></td>
                    <td>
                        <input type="checkbox" class="checkbox"> 工单审核
                        <input type="checkbox" class="checkbox"> 工单审核
                        <input type="checkbox" class="checkbox"> 工单审核
                        <input type="checkbox" class="checkbox"> 工单审核
                    </td>
                </tr>
                <tr class="permission-group">
                    <td><input type="checkbox" class="checkbox"></td>
                    <td class="module-name">销售订单审核</td>
                    <td>
                        <input type="checkbox" class="checkbox"> 工单审核
                        <input type="checkbox" class="checkbox"> 工单审核
                        <input type="checkbox" class="checkbox"> 工单审核
                        <input type="checkbox" class="checkbox"> 工单审核
                    </td>
                </tr>
            </table>
        </div>
    </div>

    <!-- 新增角色分组对话框 -->
    <div class="modal" id="addRoleGroupModal">
        <div class="modal-content">
            <div class="modal-header">
                <h3>新增角色分组</h3>
                <button class="close-btn" id="closeModal">×</button>
            </div>
            <div class="modal-body">
                <div class="form-group">
                    <label>分组名称</label>
                    <input type="text" placeholder="请输入">
                </div>
                <div class="form-group">
                    <label>角色类型</label>
                    <select>
                        <option value="">请选择角色类型</option>
                        <option value="normal">普通用户</option>
                        <option value="admin">管理员</option>
                        <option value="expert">专家</option>
                        <option value="supplier">供应商</option>
                    </select>
                </div>
            </div>
            <div class="modal-footer">
                <button class="btn btn-default" id="cancelBtn">取消</button>
                <button class="btn btn-primary" id="confirmBtn">确认</button>
            </div>
        </div>
    </div>

    <script>
        // 角色组展开/折叠逻辑
        document.querySelectorAll('.role-group-title').forEach(title => {
            title.addEventListener('click', () => {
                const roleGroup = title.parentElement;
                const roleList = roleGroup.querySelector('ul');
                
                if (roleList) {
                    title.classList.toggle('expanded');
                }
            });
        });

        // 弹出对话框逻辑
        const modal = document.getElementById('addRoleGroupModal');
        const addBtn = document.getElementById('addRoleGroupBtn');
        const closeBtn = document.getElementById('closeModal');
        const cancelBtn = document.getElementById('cancelBtn');
        const confirmBtn = document.getElementById('confirmBtn');

        // 打开对话框
        addBtn.addEventListener('click', () => {
            modal.style.display = 'flex';
        });

        // 关闭对话框的多种方式
        closeBtn.addEventListener('click', () => {
            modal.style.display = 'none';
        });

        cancelBtn.addEventListener('click', () => {
            modal.style.display = 'none';
        });

        confirmBtn.addEventListener('click', () => {
            // 这里可以添加保存逻辑
            modal.style.display = 'none';
        });

        // 点击对话框外部关闭对话框
        window.addEventListener('click', (event) => {
            if (event.target === modal) {
                modal.style.display = 'none';
            }
        });
    </script>
</body>
</html>
